﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Web;
using System.Web.Mvc;
using elfam.web.Attributes;
using elfam.web.Exceptions;
using elfam.web.Models;
using elfam.web.Paging;
using elfam.web.Paging.Prototype;
using elfam.web.ViewModels.Admin;
using NHibernate.Criterion;
using NHibernate.SqlCommand;
using NHibernate.Transform;
using Order = NHibernate.Criterion.Order;

namespace elfam.web.Controllers
{
    public class AdminController : BaseController
    {
        [Admin]
        public ActionResult ListProducts(ProductListAdminSearchCriteria searchCriteria)
        {
            ProductListAdminQueryBuilder queryBuilder = new ProductListAdminQueryBuilder(searchCriteria);
            var categories = daoTemplate.FindAll<Category>();
            var result = queryBuilder.Execute(daoTemplate.Session);
            return View(new ProductListViewModel{SearchResults = result, Categories = categories});
        }

    }

    public class ProductListRow
    {
        public int  ProductId { get; set; }
        public string   CategoryName { get; set; }
        public string   ProductName { get; set; }
        public DateTime Date { get; set; }
    }
}
